import $ from 'jquery';
import { global } from '../../filter/global-api';
import { Message } from 'element-ui'
import _common from '../commonJs/wptx_common';
import _tools from '../commonJs/wptx_tools';
import _request from '../../utils/request';
import {Loading} from 'element-ui';
// import { errors } from '../../api/error'
let _FUNCTION_NAME = "";
let _API_NAME = "";
export default {
  authLogin: _authLogin, // 登录
  authLogout: _authLogout, // 注销
}
function _authLogin(vm, data, callBack) {
  let self = vm;
  _tools.info("===> 【" + data + "】 -- > data")
  let url = _FUNCTION_NAME + "auth/login";
  let params = data
  _request({
    url: url,
    method: 'post',
    data: params
  }).then((res) => {
    _tools.info("===> 【" + url + "】 -- > API 调用成功 ")
    _tools.info(res)
    callBack(res.result);
  }).catch((error) => {
    _tools.info("===> 【" + url + "】 -- > API 调用异常 ")
    _tools.error(error);
    // callBack(null);
  });
}
function _authLogout(vm, data, callBack) {
  let self = vm;
  _tools.info("===> 【" + data + "】 -- > data")
  let url = _FUNCTION_NAME + "auth/logout";
  let params = data
  _request({
    url: url,
    method: 'post',
    data: params
  }).then((res) => {
    _tools.info("===> 【" + url + "】 -- > API 调用成功 ")
    _tools.info(res)
    callBack(res);
  }).catch((error) => {
    _tools.info("===> 【" + url + "】 -- > API 调用异常 ")
    _tools.error(error);
    // callBack(null);
  });
}
